package com.zhijian.medical.controller;

import com.zhijian.medical.entity.vo.request.RoutinePatientSearchVo;
import com.zhijian.medical.entity.vo.request.RoutineSampleRegisterVo;
import com.zhijian.medical.entity.vo.response.RoutinePatientVo;
import com.zhijian.medical.enums.PatientEnums;
import com.zhijian.medical.service.RoutinePatientService;
import com.zhijian.response.annotation.Response;
import com.zhijian.util.page.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 术中快速-病人 控制层
 *
 * @author auto
 * @version 1.0
 * @date 2024-06-26 15:42:40
 */
@Slf4j
@Controller
@RequestMapping("/fast")
@Api(tags = "术中快速-病人")
public class RoutinePatientFastController {

    @Autowired
    private RoutinePatientService service;

    /**
     * 根据id查询病人详情，包含样本列表
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/routine/patient/{id}")
    @ApiOperation("根据id查询病人详情，包含样本列表")
    public RoutinePatientVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    @Response
    @PostMapping("/routine/patient/page/register")
    @ApiOperation("分页查询")
    public Page<RoutinePatientVo> selectRegisterByCondition(@RequestBody(required = false) RoutinePatientSearchVo param) {
        if (param == null)
            param = RoutinePatientSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        param.setPatientHandleType(PatientEnums.PatientHandleTypeEnum.FAST_HANDLE.getCode());
        return service.selectPageFast(param);
    }

    /**
     * 列表查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/routine/patient/list")
    @ApiOperation("列表查询")
    public List<RoutinePatientVo> selectList(@RequestBody(required = false) RoutinePatientSearchVo param) {
        if (param == null)
            param = RoutinePatientSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectListFast(param);
    }
}
